<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<fmt:setTimeZone value="GMT+8" />
<html>
<head>
    <title>所有博客</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
        }

        body {
            background: linear-gradient(135deg, #fae18e 0%, #e4edf5 100%);
            min-height: 100vh;
            display: flex;
            justify-content: center;
            padding: 20px;
        }

        .container {
            width: 100%;
            max-width: 1200px;
        }

        /* 导航栏样式 */
        .navbar {
            background: rgba(255, 255, 255, 0.95);
            box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
            border-radius: 15px;
            padding: 0 25px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            height: 80px;
            margin-bottom: 40px;
            position: relative;
            z-index: 100;
        }

        .logo {
            display: flex;
            align-items: center;
        }

        .logo-icon {
            background: linear-gradient(135deg, #cb2711 0%, #fcca25 100%);
            width: 45px;
            height: 45px;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 12px;
        }

        .logo-icon i {
            color: white;
            font-size: 22px;
        }

        .logo-text {
            font-size: 24px;
            font-weight: 700;
            color: #2c3e50;
            letter-spacing: -0.5px;
        }

        .logo-text span {
            color: #4a6cf7;
        }

        .nav-links {
            display: flex;
            list-style: none;
        }

        .nav-links li {
            margin: 0 15px;
            position: relative;
        }

        .nav-links a {
            text-decoration: none;
            color: #4a5568;
            font-size: 17px;
            font-weight: 500;
            padding: 8px 5px;
            transition: all 0.3s ease;
            position: relative;
        }

        .nav-links a:hover {
            color: #4a6cf7;
        }

        .nav-links a::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 0;
            height: 3px;
            background: linear-gradient(90deg, #6a11cb, #2575fc);
            border-radius: 10px;
            transition: width 0.4s ease;
        }

        .nav-links a:hover::after {
            width: 100%;
        }

        .nav-buttons {
            display: flex;
            align-items: center;
        }

        .search-box {
            position: relative;
            margin-right: 20px;
        }

        .search-box input {
            padding: 10px 15px 10px 40px;
            border-radius: 30px;
            border: 1px solid #e2e8f0;
            background: #f8fafc;
            width: 200px;
            font-size: 15px;
            transition: all 0.3s ease;
        }

        .search-box input:focus {
            outline: none;
            border-color: #a3bffa;
            box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.2);
            width: 220px;
        }

        .search-icon {
            position: absolute;
            left: 15px;
            top: 50%;
            transform: translateY(-50%);
            color: #a0aec0;
        }

        .btn {
            padding: 10px 25px;
            border-radius: 30px;
            font-weight: 600;
            font-size: 15px;
            cursor: pointer;
            transition: all 0.3s ease;
            border: none;
        }

        .login-btn {
            background: transparent;
            color: #f7b24a;
            border: 2px solid #f7da4a;
            margin-right: 10px;
        }

        .login-btn:hover {
            background: #f7da4a;
            color: white;
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgb(243, 230, 168);
        }

        .register-btn {
            background: linear-gradient(135deg, #cb2111 0%, #fcbf25 100%);
            color: white;
        }

        .register-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgb(245, 231, 167);
        }

        .mobile-menu-btn {
            display: none;
            background: transparent;
            border: none;
            font-size: 24px;
            color: #4a5568;
            cursor: pointer;
        }

        /* 文章列表样式 */
        .articles-container {
            background: white;
            border-radius: 15px;
            padding: 40px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
            margin-bottom: 40px;
        }

        .articles-container h1 {
            color: #2c3e50;
            margin-bottom: 30px;
            font-size: 32px;
            border-bottom: 3px solid #f7da4a;
            padding-bottom: 15px;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .page-info {
            font-size: 16px;
            color: #718096;
            font-weight: normal;
        }

        .article-list {
            display: flex;
            flex-direction: column;
            gap: 25px;
            margin-bottom: 30px;
        }

        .article-item {
            display: flex;
            flex-direction: column;
            padding: 20px;
            background: #f8fafc;
            border-radius: 12px;
            transition: all 0.3s ease;
            border-left: 4px solid #f7da4a;
        }

        .article-item:hover {
            transform: translateY(-5px);
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
            background: white;
        }

        .article-title {
            font-size: 22px;
            font-weight: 700;
            color: #2c3e50;
            margin-bottom: 12px;
            transition: all 0.3s ease;
        }

        .article-title a {
            text-decoration: none;
            color: inherit;
            display: flex;
            align-items: center;
        }

        .article-title a:hover {
            color: #cb2711;
        }

        .article-title a i {
            margin-left: 10px;
            font-size: 16px;
            opacity: 0.7;
        }

        .article-meta {
            display: flex;
            align-items: center;
            margin-bottom: 15px;
            font-size: 14px;
            color: #718096;
        }

        .article-meta span {
            display: flex;
            align-items: center;
            margin-right: 20px;
        }

        .article-meta i {
            margin-right: 6px;
            font-size: 16px;
        }

        .article-content {
            color: #4a5568;
            line-height: 1.7;
            font-size: 16px;
            margin-bottom: 15px;
            display: -webkit-box;
            -webkit-line-clamp: 3;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }

        .article-footer {
            display: flex;
            justify-content: space-between;
             align-items: center;
            margin-top: 15px;
        }

        .article-author {
            display: flex;
            align-items: center;
            font-weight: 600;
            color: #b0e5f5;
        }

        .article-author i {
            margin-right: 8px;
        }

        .no-articles {
            text-align: center;
            padding: 50px 0;
            color: #718096;
            font-size: 18px;
        }

        .no-articles i {
            font-size: 48px;
            margin-bottom: 20px;
            color: #cbd5e0;
        }

        /* 分页样式 */
        .pagination {
            display: flex;
            justify-content: center;
            margin-top: 30px;
        }

        .pagination-container {
            display: flex;
            list-style: none;
            border-radius: 10px;
            background: #f8fafc;
            padding: 5px;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
        }

        .page-item {
            margin: 0 5px;
        }

        .page-link {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 40px;
            height: 40px;
            border-radius: 10px;
            text-decoration: none;
            color: #4a5568;
            font-weight: 600;
            transition: all 0.3s ease;
        }

        .page-link:hover {
            background: #e2e8f0;
            color: #2c3e50;
        }

        .page-item.active .page-link {
            background: linear-gradient(135deg, #cb2111 0%, #fcbf25 100%);
            color: white;
            box-shadow: 0 4px 10px rgba(203, 33, 17, 0.2);
        }

        .page-item.disabled .page-link {
            color: #cbd5e0;
            cursor: not-allowed;
        }

        .page-item.disabled .page-link:hover {
            background: transparent;
        }

        /* 移动设备适配 */
        @media (max-width: 992px) {
            .nav-links {
                display: none;
            }

            .mobile-menu-btn {
                display: block;
            }

            .navbar {
                padding: 0 20px;
            }

            .search-box input {
                width: 160px;
            }

            .search-box input:focus {
                width: 180px;
            }
        }

        @media (max-width: 768px) {
            .search-box {
                display: none;
            }

            .nav-buttons .btn {
                padding: 8px 15px;
                font-size: 14px;
            }

            .logo-text {
                font-size: 20px;
            }

            .logo-icon {
                width: 38px;
                height: 38px;
            }

            .article-title {
                font-size: 19px;
            }

            .article-meta {
                flex-wrap: wrap;
            }

            .article-meta span {
                margin-bottom: 8px;
            }

            .articles-container h1 {
                flex-direction: column;
                align-items: flex-start;
            }

            .page-info {
                margin-top: 10px;
                font-size: 14px;
            }
        }
    </style>
</head>
<body>
<div class="container">
    <!-- 导航栏 -->
    <nav class="navbar">
        <div class="logo"><div class="logo-icon">
        </div>
            <div class="logo-text"> Sun&Hope </div>
        </div>

        <ul class="nav-links">
            <li><a href="welcome"><i class="fas fa-home"></i> 首页 </a></li>
            <li><a href="allArticle"><i class="fas fa-folder"></i> 所有博客 </a></li>
            <li><a href="getPics"><i class="fas fa-archive"></i> 夺冠时刻 </a></li>
            <li><a href="#"><i class="fas fa-user"></i> 精彩合集 </a></li>
        </ul>

        <div class="nav-buttons">
                <div class="search-box">
                    <form action="${pageContext.request.contextPath}/searchArticle" method="get">
                        <i class="fas fa-search search-icon"></i>
                        <input type="text" name="keyword" placeholder="搜索文章...">
                        <button type="submit" style="display: none;"></button>
                    </form>
                </div>

            <button class="btn register-btn"><a href="backend">后台管理</a></button>
            <button class="btn login-btn"><a href="out">退出登录</a></button>
            <button class="mobile-menu-btn">
                <i class="fas fa-bars"></i>
            </button>
        </div>
    </nav>

    <!-- 文章列表区域 -->
    <div class="articles-container">
        <!-- 显示分页信息 -->
        <h1>
            <span><i class="fas fa-newspaper"></i> 所有博客</span>
            <%--<span class="page-info">第 ${currentPage} 页 / 共 ${totalPages} 页</span>--%>
        </h1>


        <div class="article-list">
            <c:choose>
                <c:when test="${not empty articles}">
                    <c:forEach items="${articles}" var="article">
                        <div class="article-item">
                            <h2 class="article-title">
                                <a href="articleDetail?id=${article.id}">
                                        ${article.title} <i class="fas fa-external-link-alt"></i>
                                </a>
                            </h2>

                            <div class="article-meta">
                                <span><i class="far fa-calendar-alt"></i>
                                    <fmt:formatDate value="${article.createTime}" pattern="yyyy年MM月dd日" />
                                </span>
                            </div>

                            <div class="article-content">
                                    ${article.content}
                            </div>

                            <div class="article-footer">
                                <div class="article-author">
                                    <i class="fas fa-user-edit"></i> ${article.author}
                                </div>
                            </div>
                        </div>
                    </c:forEach>
                </c:when>
                <c:otherwise>
                    <div class="no-articles">
                        <i class="fas fa-inbox"></i>
                        <p>暂时没有文章，快去发布一篇吧！</p>
                    </div>
                </c:otherwise>
            </c:choose>
        </div>

        <!-- 分页导航 - 确保不传递pageSize参数 -->
        <div class="pagination">
            <ul class="pagination-container">
                <!-- 上一页 -->
                <li class="page-item ${currentPage == 1 ? 'disabled' : ''}">
                    <a class="page-link" href="allArticle?page=${currentPage - 1}">
                        <i class="fas fa-chevron-left"></i>
                    </a>
                </li>

                <!-- 页码 -->
                <c:forEach begin="1" end="${totalPages}" var="pageNum">
                    <li class="page-item ${pageNum == currentPage ? 'active' : ''}">
                        <a class="page-link" href="allArticle?page=${pageNum}">${pageNum}</a>
                    </li>
                </c:forEach>

                <!-- 下一页 -->
                <li class="page-item ${currentPage == totalPages ? 'disabled' : ''}">
                    <a class="page-link" href="allArticle?page=${currentPage + 1}">
                        <i class="fas fa-chevron-right"></i>
                    </a>
                </li>
            </ul>
        </div>
    </div>
</div>

<script>
    // 移动菜单切换功能
    document.querySelector('.mobile-menu-btn').addEventListener('click', function() {
        const navLinks = document.querySelector('.nav-links');
        if (navLinks.style.display === 'flex') {
            navLinks.style.display = 'none';
        } else {
            navLinks.style.display = 'flex';
            navLinks.style.flexDirection = 'column';
            navLinks.style.position = 'absolute';
            navLinks.style.top = '80px';
            navLinks.style.left = '0';
            navLinks.style.right = '0';
            navLinks.style.background = 'white';
            navLinks.style.padding = '20px';
            navLinks.style.boxShadow = '0 10px 20px rgba(0,0,0,0.1)';
            navLinks.style.borderBottomLeftRadius = '15px';
            navLinks.style.borderBottomRightRadius = '15px';

            navLinks.querySelectorAll('li').forEach(li => {
                li.style.margin = '10px 0';
            });
        }
    });

    // 搜索框聚焦效果
    const searchInput = document.querySelector('.search-box input');
    if (searchInput) {
        searchInput.addEventListener('focus', function() {
            this.parentElement.style.transform = 'scale(1.05)';
        });

        searchInput.addEventListener('blur', function() {
            this.parentElement.style.transform = 'scale(1)';
        });
    }
</script>
</body>
</html>